var websiteConfig = new XFApp.client();
XFApp.client.prototype.websiteConfig = {
	successCode : "10000",
	submitConfig : function() {
		var params = $("#configForm").serialize();
		webDialogUtil.simpleConfrimAlert("是否确认提交", function(){
			$.ajax({
				url : basePath+"/website/save",
				dataType : 'json',
				data  : params,
				type : 'post',
				success : function(data) {
					if(data.code!=10000){
						webDialogUtil.simpleAlert(data.msg, "温馨提示");
					}else{
						webDialogUtil.simpleAlert("处理成功", "温馨提示");
						var config = data.result;
						$("#websiteConfigOne_id").val(config.websiteConfigOne.id);
//						$("#websiteConfigTwo_id").val(config.websiteConfigTwo.id);
//						$("#websiteConfigThree_id").val(config.websiteConfigThree.id);
					}
				},
				error:function(){
					webDialogUtil.simpleAlert("处理异常，请联系开发人员", "温馨提示");
				}
			});
		});
	},
	formValidate : function(){
		$("#configForm").validate({
	        rules: {
	        	'websiteConfigOne.title': "required",
	        	'websiteConfigOne.bakNo': "required",
	        	'websiteConfigOne.copyright': "required",
	        	'websiteConfigOne.copylimit': "required",
	        	'websiteConfigOne.support': "required"
	        	
//	        	'websiteConfigTwo.title': "required",
//	        	'websiteConfigTwo.bakNo': "required",
//	        	'websiteConfigTwo.copyright': "required",
//	        	'websiteConfigTwo.support': "required",
//	        	
//	        	'websiteConfigThree.title': "required",
//	        	'websiteConfigThree.copyright': "required",
//	        	'websiteConfigThree.support': "required"
			  },
			 messages: {
				 	'websiteConfigOne.title': "标题不能为空",
		        	'websiteConfigOne.bakNo': "备案号不能为空",
		        	'websiteConfigOne.copyright': "版权所有不能为空",
		        	'websiteConfigOne.copylimit': "版权期限不能为空",
		        	'websiteConfigOne.support': "技术支持不能为空"
		        	
//		        	'websiteConfigTwo.title': "标题不能为空",
//		        	'websiteConfigTwo.bakNo': "备案号不能为空",
//		        	'websiteConfigTwo.copyright': "版权所有不能为空",
//		        	'websiteConfigTwo.support': "技术支持不能为空",
//		        	
//		        	'websiteConfigThree.title': "标题不能为空",
//		        	'websiteConfigThree.bakNo': "备案号不能为空",
//		        	'websiteConfigThree.support': "技术支持不能为空"
			  }
	    });
		$("#configForm").validate();
	},
	event : function() {
		_this = this;
		_this.formValidate();
		$("#submit_btn").on("click",function(){
			if($("#configForm").validate().form()){
				_this.submitConfig();
			}
		});
	},
};
$(function() {
	websiteConfig.websiteConfig.event();
	
});